<%
'/**
' * @name          wx-qq-function    
' * @copyright     http://code.google.com/u/wxframework/
' * @version       $Id$
' * @author        $Author$  <fmais@163.com>
' * 
' * <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
'**/

Public Function isValidEmail(email)
'检查EMAIL格式是否正确
	dim names, name, i, c
	isValidEmail = true
	names = split(email, "@")
	if ubound(names) <> 1 then isValidEmail = false : exit function
	for each name in names
	   if len(name) <= 0 then isValidEmail = false : exit function
	   for i = 1 to len(name)
		 c = lcase(mid(name, i, 1))
		 if instr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not isnumeric(c) then isValidEmail = false : exit function
	   next
	   if left(name, 1) = "." or right(name, 1) = "." Then  isValidEmail = false : exit function
	next
	if instr(names(1), ".") <= 0 then isValidEmail = false : exit function
	i = len(names(1)) - instrrev(names(1), ".")
	If i <> 2 and i <> 3 then  isValidEmail = false : exit function
	If instr(email, "..") > 0 then  isValidEmail = false 
End Function


Public Function inre(str)
'输入格式过滤
 select case lcase(str)
  case  "nore"'不重复输入
  inre="onkeyup='value=((value.replace(/(.).*\1/g,""$1"")+value.replace(new RegExp(""[""+value.replace(/(.).*\1/g,""$1"")+""]"",""g""),"""")))' onbeforepaste='value=((value.replace(/(.).*\1/g,""$1"")+value.replace(new RegExp(""[""+value.replace(/(.).*\1/g,""$1"")+""]"",""g""),"""")))'"
  case  "en"'只能输入英文
  inre="onkeyup=""value=value.replace(/[^A-Za-z]/g,'') "" onbeforepaste=""clipboardData.setData('text',clipboardData.getData('text').replace(/[^A-Za-z]/g,''))"""
  case "cn" '只能输汉字
  inre="onkeyup=""value=value.replace(/[^\u4E00-\u9FA5]/g,'')"" onbeforepaste=""clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))"""
  case "chs" '只能输入全角字符
  inre="onkeyup=""value=value.replace(/[^\uFF00-\uFFFF]/g,'')"" onbeforepaste=""clipboardData.setData('text',clipboardData.getData('text').replace(/[^\uFF00-\uFFFF]/g,''))"""
  case "num" '只能输入数字
  inre="onkeyup=""value=value.replace(/[^\d]/g,'') "" onbeforepaste=""clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"""
  case  "ennum"'只能输入数字和英文
  inre="onkeyup=""value=value.replace(/[\W]/g,'') "" onbeforepaste=""clipboardData.setData('text',clipboardData.getData('text').replace(/[\W]/g,''))"""
  case else
  inre=""
 end select
End Function 

Public Function Formatdate3(dateval ,flag)
'自定义格日期式化
 Dim tempdate,temparray,yyyyhhdd,flagarray,tmp,timei,yyyy,mmstr,mm,ddstr,dd,returnsrt
 If isempty(dateval) or isnull(dateval) Then
   returnsrt=""
 Else
   tempdate=FormatDateTime(dateval, 2)&" "&FormatDateTime(dateval, 4)
   temparray=split( tempdate ," ")
   yyyyhhdd=temparray(0)

   flagarray=split(flag,"-")
   tmp=split(yyyyhhdd,"-")
   For timei=0 to ubound(flagarray)
      If flagarray(timei)="yy" Then
      yyyy=mid(tmp(0),3)
      ElseIf flagarray(timei)="yyyy" Then
      yyyy=tmp(0)
      ElseIf flagarray(timei)="mm" Then
      mmstr=""
      If tmp(1)+0<10 Then
        mmstr="0"
      End If
      mm=mmstr&tmp(1)
     ElseIf flagarray(timei)="m" Then
       mm=tmp(1)
     ElseIf flagarray(timei)="dd" Then
     ddstr=""
     If tmp(2)+0<10 Then
     ddstr="0"
     End If
     dd=ddstr&tmp(2)
     ElseIf flagarray(timei)="d" Then
       dd=tmp(2)
     Else
       ddstr=""
     If tmp(2)+0<10 Then
     ddstr="0"
     End If
       dd= ddstr&tmp(2)&" " &temparray(1)
      End If
   Next
    returnsrt=yyyy&"-"&mm&"-"&dd
  If yyyy="" Then
   returnsrt=mm&"-"&dd
  End If
  If mm="" Then
   returnsrt=dd
  End If
 End If
 Formatdate3=returnsrt
End Function

Public Function GetNewFileName()
'按日期生成永不重复的文件名或序列号
	Randomize
	dim ranNum,dtNow
	dtNow=Now()
	ranNum=int(90000*rnd)+10000
	GetNewFileName=year(dtNow) & right("0" & month(dtNow),2) & right("0" & day(dtNow),2) & right("0" & hour(dtNow),2) & right("0" & minute(dtNow),2) & right("0" & second(dtNow),2) & ranNum
End Function
%>

